package cn.itcast.user.web;

import cn.itcast.user.config.PropertiesConfig;
import cn.itcast.user.pojo.User;
import cn.itcast.user.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("user")
//@RefreshScope  //方式一.实现热部署更新
public class UserController {

    //读取到 nacos中 userservice-dev.yaml的配置信息
//    @Value("${user.name}")
//    private String value;

    @Autowired
    private PropertiesConfig propertiesConfig;

    @Autowired
    private UserService userService;

    /**
     * 路径： /user/110
     *
     * @param id 用户id
     * @return 用户
     */
    @GetMapping("/{id}")
    public User queryById(@PathVariable("id") Long id) {


        return userService.queryById(id);
    }

    @GetMapping("/hello")
    public String printValue() {
        return propertiesConfig.getName() + propertiesConfig.getPassword() + propertiesConfig.getName1();
    }
}
